<template>
		<view>
			<view class="button" style="text-align: center;margin-top: 20%;">
				 <navigator url="../checked/checked"><button size="mini" type="primary"  @click="signed">点击签到</button></navigator>
			</view>
			<view class="data">
				<text >签到日期为：{{y}}年{{m}}月{{d}}日{{h}}时{{mm}}分{{s}}秒</text>
			</view>
		</view>
</template>

<script>
	export default {
		data() {
			return {
				longitude:'',
				latitude:'',
				y:'',
				m:'',
				d:'',
				h:'',
				mm:'',
				s:'',
				Time:''
			}
		},
	        methods: {
				onLoad() {
					//获取当前时间
				console.log(this.traversalTime(new Date().getTime()),'当前时间')
				 },
				 addTimes(m){return m<10?'0'+m:m },
				 traversalTime(timestamp) {
				   //timestamp(时间戳)是整数，否则要parseInt转换
				   var time = new Date(timestamp);
				   var y = time.getFullYear();
				   var m = time.getMonth() + 1;
				   var d = time.getDate();
				   var h = time.getHours();
				   var mm = time.getMinutes();
				   var s = time.getSeconds();
				 				this.y=y;
				 				this.m=m;
				 				this.d=d;
				 				this.h=h;
				 				this.mm=mm;
				 				this.s=s;
				 },
				signed(){
					uni.getlocation({
						url:"http://rap2api.taobao.org/app/mock/286869/personal/checkIn",
						type: 'wgs84',
						    success:res=> {
								this.longitude=res.longitude;
								this.latitude=res.latitude;
						        console.log('当前位置的经度：' + res.longitude);
						        console.log('当前位置的纬度：' + res.latitude);
								console.log("签到成功+1");
						    }
					});
					uni.request({
						url:"http://rap2api.taobao.org/app/mock/286869/personal/checkIn",
						method:"POST",
						data:{
							longitude:this.longitude,
							latitude:this.latitude,
							year:this.y,
							month:this.m,
							day:this.d,
							hour:this.h,
							minute:this.mm,
							second:this.s
						},
						success:res=>{
							console.log("传参成功");
						}
					})
				}
	        }
	    }
	
</script>

<style>
	.data{
		margin-top: 10%;
		
	}
</style>
